package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.YlAfterAccount;
import com.ruoyi.system.service.IYlAfterAccountService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 后端账户管理Controller
 * 
 * @author ruoyi
 * @date 2022-02-18
 */
@RestController
@RequestMapping("/afteraccount")
public class YlAfterAccountController extends BaseController
{
    @Autowired
    private IYlAfterAccountService ylAfterAccountService;

    /**
     * 查询后端账户管理列表
     */
    @RequiresPermissions("ylsystem:afteraccount:list")
    @GetMapping("/list")
    public TableDataInfo list(YlAfterAccount ylAfterAccount)
    {
        startPage();
        List<YlAfterAccount> list = ylAfterAccountService.selectYlAfterAccountList(ylAfterAccount);
        return getDataTable(list);
    }

    /**
     * 导出后端账户管理列表
     */
    @RequiresPermissions("ylsystem:afteraccount:export")
    @Log(title = "后端账户管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YlAfterAccount ylAfterAccount)
    {
        List<YlAfterAccount> list = ylAfterAccountService.selectYlAfterAccountList(ylAfterAccount);
        ExcelUtil<YlAfterAccount> util = new ExcelUtil<YlAfterAccount>(YlAfterAccount.class);
        util.exportExcel(response, list, "后端账户管理数据");
    }

    /**
     * 获取后端账户管理详细信息
     */
    @RequiresPermissions("ylsystem:afteraccount:query")
    @GetMapping(value = "/{accountId}")
    public AjaxResult getInfo(@PathVariable("accountId") Long accountId)
    {
        return AjaxResult.success(ylAfterAccountService.selectYlAfterAccountByAccountId(accountId));
    }

    /**
     * 新增后端账户管理
     */
    @RequiresPermissions("ylsystem:afteraccount:add")
    @Log(title = "后端账户管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YlAfterAccount ylAfterAccount)
    {
        return toAjax(ylAfterAccountService.insertYlAfterAccount(ylAfterAccount));
    }

    /**
     * 修改后端账户管理
     */
    @RequiresPermissions("ylsystem:afteraccount:edit")
    @Log(title = "后端账户管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YlAfterAccount ylAfterAccount)
    {
        return toAjax(ylAfterAccountService.updateYlAfterAccount(ylAfterAccount));
    }

    /**
     * 删除后端账户管理
     */
    @RequiresPermissions("ylsystem:afteraccount:remove")
    @Log(title = "后端账户管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{accountIds}")
    public AjaxResult remove(@PathVariable Long[] accountIds)
    {
        return toAjax(ylAfterAccountService.deleteYlAfterAccountByAccountIds(accountIds));
    }
}
